package util.ip;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Regex {
	
	String ipRegex = "^([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)(\\.([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)){3}$";
	Pattern ipPattern;
	Matcher ipMatcher;
	
	public Regex() {
		ipPattern = Pattern.compile(ipRegex);
	}
	
	public boolean isIpv4(String ip) {
		
		ipMatcher = ipPattern.matcher(ip);
		return ipMatcher.matches();
		
	}

}
